<?php

/**
 * This is the model class for table "callback".
 *
 * The followings are the available columns in table 'callback':
 * @property string $sr_number
 * @property string $date
 * @property integer $idqshift
 * @property string $time
 * @property string $isAssigned
 * @property string $comments
 * @property string $created_by
 * @property string $new_owner
 * @property integer $team_id
 *
 * The followings are the available model relations:
 * @property User $createdBy
 * @property User $newOwner
 * @property Qshift $idqshift0
 * @property Team $team
 */
class Callback extends CActiveRecord
{


	public static $yesNoValues= array('0'=>'No', '1'=>'Yes');

	 public static function getYesNoValue($bin=null){
	 
		if($bin!==null)
			return self::$yesNoValues[$bin];
		return self::$yesNoValues;
	 }


	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Callback the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'callback';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('sr_number, date, idqshift, time, team_id', 'required'),
			array('idqshift, team_id', 'numerical', 'integerOnly'=>true),
			array('sr_number, created_by, new_owner', 'length', 'max'=>10),
			array('isAssigned', 'length', 'max'=>1),
			array('comments', 'length', 'max'=>100),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('sr_number, date, idqshift, time, isAssigned, comments, created_by, new_owner, team_id', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'createdBy_relation' => array(self::BELONGS_TO, 'User', 'created_by'),
			'newOwner_relation' => array(self::BELONGS_TO, 'User', 'new_owner'),
			'qshift_relation' => array(self::BELONGS_TO, 'Qshift', 'idqshift'),
			'team_relation' => array(self::BELONGS_TO, 'Team', 'team_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'sr_number' => 'C3 SR#',
			'date' => 'Date',
			'idqshift' => 'Q-Shift',
			'time' => 'Time',
			'isAssigned' => 'Is Assigned?',
			'created_by' => 'Created By',
			'new_owner' => 'New Owner CCO',
			'comments' => 'Comments',
			'team_id' => 'Team',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('sr_number',$this->sr_number,true);
		$criteria->compare('date',$this->date,true);
		$criteria->compare('idqshift',$this->idqshift);
		$criteria->compare('time',$this->time,true);
		$criteria->compare('isAssigned',$this->isAssigned,true);
		$criteria->compare('comments',$this->comments,true);
		$criteria->compare('created_by',$this->created_by,true);
		$criteria->compare('new_owner',$this->new_owner,true);
		$criteria->compare('team_id',$this->team_id);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}